import React, { Component } from 'react'
import {
  createAppContainer,
  createStackNavigator,
  StackViewTransitionConfigs
} from 'react-navigation'
import createAnimatedSwitchNavigator from 'react-navigation-animated-switch'
import { Transition } from 'react-native-reanimated'
import StackViewStyleInterpolator from 'react-navigation-stack/src/views/StackView/StackViewStyleInterpolator'
import { IS_IOS } from './utils/ScreenUtil'

/* pageP */
import LaunchPage from './pageP/launch' /* 启动 */
import OneLogin from './pageP/login/one-login' /* 一键登录 */
import VerifyCodeLogin from './pageP/login/verify-code-login' /* 短信验证码登录 */
import CommonChangePhone from './pageP/common/common-change-phone' /* 可配置通用输入 */
import CommonInputPage from './pageP/common/common-input-page' /* 可配置通用输入 */
import CommonWebView from './pageP/common/common-webview' /* 可配置通用webview */
import CommonListCity from './pageP/common/common-list-city/index.js' /* 通用城市 */
import HomeSearch from './pageP/home/home-search/index'
import CommonInputListPage from './pageP/common/common-input-list-page/index'

/* pageB */

import BMainTab from './pageB/tabbar' /* B Tabbar */
// import BMessage from './pageB/message/message-page' /* B 消息 */
// import BMain from './pageB/main/main-page' /* B 消息 */
import BSetPage from './pageB/set/set-page' /* B 设置主页 */
import BMineCompany from './pageB/company/mine-company' /* B 公司主页 */
import BUserInfoBasic from './pageB/user-info/user-info-basic' /* C 用户基础信息 */
import BUserAvator from './pageB/user-info/user-info-avator' /* B 初次用户头像 */
import BFirstUserInfo from './pageB/first-login/first-user-info' /* B 初次用户基础信息 */
import BCompanyApplyName from './pageB/company/company-apply-name' /* B 公司全称 */
import BCompanyApplyLicence from './pageB/company/company-apply-license' /* B 公司营业执照 */
import BCompanyApplyJoin from './pageB/company/company-apply-join' /* B 加入企业 */
import CompanyHomepage from './pageB/company/company-homepage' /* 我的企业主页 */
import BusinessAddress from './pageB/company/company-business-address' /* B 企业地址页面 */
import BusinessIndustry from './pageB/company/company-business-industry' /* B 企业行业 */
import Administrators from './pageB/company/company-Administrators' /* B 公司成员页面 */
import JobPartTime from './pageB/part/job-part-time' /* B 兼职岗位页面 */
import PartTimeRelease from './pageB/part/Part-time-release' /* 兼职岗位页面 */
import BMemberOpenPre from './pageB/member/member-open-pre' /* B 其他按钮点击开会员列表页面 */
import BMemberOpen from './pageB/member/member-open' /* B 开会员列表页面 */
import BMemberDetail from './pageB/member/member-detail' /* B 已开开会员列表页面 */
import BMemberOrder from './pageB/member/member-order' /* B 订单 */
import CompanyWelfare from './pageB/company/company-welfare' /* B 公司福利 */
import CompanyMapView from './pageB/company/company-mapview' /* 获取企业地址 */
import AddSite from './pageB/part/add-site' /* B 工作地址列表 */
import CompanyAlbums from './pageB/company/company-album' /* B 公司相册 */
import BCompanyApplyFamous from './pageB/company/company-apply-famous' /* B 名企申请 */
import CompanyAvator from './pageB/company/company-avator' // 上传头像
import ChatPageB from './pageB/message/chat-page/index' /* B 聊天页面 */
import ConpanyInfo from './pageB/company/conpanyInfo'
import SchoolRecruitment from './pageB/part/school-recruitment/index'

/* pageC */
import CMainTab from './pageC/tabbar' /* C tabbar */
import CSetPage from './pageC/set/set-page' /* B 设置主页 */
import CFirstUserInfo from './pageC/first-login/first-user-info' /* C 初次—用户基础信息 */
import CFirstJobNature from './pageC/first-login/first-job-nature' /* C 初次—用户求职意愿-工作性质 */
import CFirstJobArea from './pageC/first-login/first-job-area' /* C 初次—用户求职意愿-工作地区 */
import CFirstJobExpected from './pageC/first-login/first-job-expected' /* C 初次—用户求职意愿-工作岗位分类 */
import CUserAvator from './pageC/user-info/user-info-avator' /* C 用户头像 */
import CUserInfoBasic from './pageC/user-info/user-info-basic' /* C 用户基础信息 */
import CUserJobIntentionManager from './pageC/user-info/user-job-intention-manager' /* C 用求职意愿列表 */
import CUserJobIntentionEdit from './pageC/user-info/user-job-intention-edit' /* C 用求职意愿编辑/新增 */
import CUserJobNature from './pageC/user-info/user-job-nature' /* C 用求职意愿-工作性质 */
import CUserJobArea from './pageC/user-info/user-job-area' /* C 用求职意愿-工作地区 */
import CUserJobExpected from './pageC/user-info/user-job-expected' /* C 用求职意愿-工作岗位分类 */
import CUserSelfEvalution from './pageC/user-info/user-self-evalution' /* C 用户自我评价 */
import CResumeDetail from './pageC/mine/resume-detail'
import CEducationInfo from './pageC/user-info/education-info'
import CWorkExperience from './pageC/user-info/work-experience'
import CEducationInfoManager from './pageC/user-info/education-info-manager'
import CWorkExperienceManager from './pageC/user-info/work-experience-manager'
import CJobCollection from './pageC/user-info/job-collection'
import CMyPhotoAlbums from './pageC/user-info/my-photo-albums'
import WorkDescriptionPage from './pageC/user-info/work-description-page/index'
import TabView from './pageC/user-info/tab-view/index'
import CJobdetail from './pageC/position/job-detail/index'
import TestFlatList from './pageC/test/TestFlatList'
import BPersonCollection from './pageB/user-info/person-collection/index'
import CCommunicationHistory from './pageC/user-info/communication-history-c'
import BCommunicationHistory from './pageB/user-info/communication-history-b'
import TestIndex from './pageC/test/TestIndex'
import TestScrollFlatList from './pageC/test/TestScrollFlatList'
import TestSectionList from './pageC/test/TestSectionList'
import CompanyReport from './pageC/position/company-report'
import FamousList from './pageC/position/famous-list' // 名企列表
import LiveDetail from './pageC/live/live-detail/index' // 直播详情
import CChatPage from 'src/pageC/message/chat-page/index'
import BChatPage from 'src/pageB/message/chat-page/index'
import TestTabView from 'src/pageC/test/TestTabView'
import RecommendList from 'src/pageC/message/recommend-list'
import TestHomePage from 'src/pageC/test/TestHomePage'
import CPositionPage from 'src/pageC/position/position-page/index2' // 名企列表
import ThrowResume from 'src/pageC/throwResume' // 投递简历页面
import TestPolyvVodView from 'src/pageC/test/TestPolyvVodView'
import { TestViewShot } from 'src/pageC/test/TestViewShot' // 名企列表
import LiveSubscribe from 'src/pageC/live/live-subscribe/index' // 直播预约/收藏列表
import { TestViewComponent } from 'src/pageC/test/TestViewComponent' // 名企列表
/* C 岗位详情 */

/* C端配置开始 */
/* iOS里需要present的页面 */
const IOS_MODAL_ROUTES = ['VerifyCodeLogin']
const dynamicModalTransition = (transitionProps, prevTransitionProps) => {
  const isModal =
    IOS_MODAL_ROUTES.some(
      screenName => screenName === transitionProps.scene.route.routeName
    )
  return StackViewTransitionConfigs.defaultTransitionConfig(
    transitionProps,
    prevTransitionProps,
    isModal
  )
}
const MainRouteConfigsC = {
  OneLogin,
  VerifyCodeLogin,
  CommonChangePhone,
  CommonWebView,
  CommonInputPage,
  CommonInputListPage,
  CommonListCity,
  CUserInfoBasic,
  CUserAvator,
  CUserJobIntentionManager,
  CUserJobIntentionEdit,
  CUserJobNature,
  CUserJobArea,
  CUserJobExpected,
  CUserSelfEvalution,
  CResumeDetail: CResumeDetail,
  CEducationInfo: CEducationInfo,
  CWorkExperience: CWorkExperience,
  CEducationInfoManager: CEducationInfoManager,
  CWorkExperienceManager: CWorkExperienceManager,
  CJobCollection: CJobCollection,
  CMyPhotoAlbums: CMyPhotoAlbums,
  CMainTab: CMainTab,
  CPositionPage,
  CSetPage,
  CFirstUserInfo,
  CFirstJobNature,
  CFirstJobArea,
  CFirstJobExpected,
  WorkDescriptionPage,
  ChatPage: CChatPage,
  ChatPageB: BChatPage,
  CJobdetail,
  TabView,
  CompanyHomepage,
  TestFlatList,
  CCommunicationHistory,
  TestIndex,
  TestScrollFlatList,
  TestSectionList,
  CompanyReport,
  HomeSearch,
  FamousList,
  LiveDetail,
  TestTabView,
  RecommendList,
  TestHomePage,
  ThrowResume,
  TestPolyvVodView,
  TestViewShot,
  TestViewComponent,
  LiveSubscribe
}

const MainStackNavigatorConfigC = {
  initialRouteName: 'CMainTab',
  // initialRouteName: 'TestTabView',
  // initialRouteName: 'TestViewShot',
  // initialRouteName: 'TestPolyvVodView',
  // initialRouteName: 'HomeSearch',
  // initialRouteName: 'TestScrollFlatList',
  // initialRouteName: 'TestSectionList',
  // initialRouteName: 'TestIndex',
  headerMode: 'none',
  transitionConfig:
    IS_IOS
      ? dynamicModalTransition
      : () => ({
        screenInterpolator: StackViewStyleInterpolator.forHorizontal
      }),
  defaultNavigationOptions: {
    gesturesEnabled: true,
    headerBackTitle: '返回',
    headerTruncatedBackTitle: '返回',
    headerTitleStyle: {
      flex: 1,
      textAlign: 'center'
    }
  }
}
const CMainNavigator = createStackNavigator(
  MainRouteConfigsC,
  MainStackNavigatorConfigC
)

/* C端配置结束 */

/* B端配置开始 */
const MainRouteConfigsB = {
  OneLogin,
  VerifyCodeLogin,
  CommonChangePhone,
  CommonInputPage,
  CommonWebView,
  CommonListCity,
  BFirstUserInfo,
  BUserInfoBasic,
  BUserAvator,
  BCompanyApplyName,
  BCompanyApplyLicence,
  BCompanyApplyJoin,
  BMainTab,
  BSetPage,
  BMineCompany,
  CompanyHomepage,
  BCompanyApplyFamous,
  BusinessAddress,
  BusinessIndustry,
  Administrators,
  JobPartTime,
  PartTimeRelease,
  CompanyWelfare,
  CompanyMapView,
  AddSite,
  BMemberOpenPre,
  BMemberOpen,
  BMemberDetail,
  BMemberOrder,
  CompanyAlbums,
  CJobdetail,
  CResumeDetail,
  ChatPage: CChatPage,
  ChatPageB: BChatPage,
  CompanyAvator,
  BPersonCollection,
  BCommunicationHistory,
  HomeSearch,
  CJobCollection,
  SchoolRecruitment,
  ThrowResume,
  ConpanyInfo
}

const MainStackNavigatorConfigB = {
  initialRouteName: 'BMainTab',
  headerMode: 'none',
  transitionConfig:
    IS_IOS
      ? dynamicModalTransition
      : () => ({
        screenInterpolator: StackViewStyleInterpolator.forHorizontal
      }),
  defaultNavigationOptions: {
    gesturesEnabled: true,
    headerBackTitle: '返回',
    headerTruncatedBackTitle: '返回',
    headerTitleStyle: {
      flex: 1,
      textAlign: 'center'
    }
  }
}
const BMainNavigator = createStackNavigator(
  MainRouteConfigsB,
  MainStackNavigatorConfigB
)
/* B端配置结束 */
const SwitchRouteConfigs = {
  LaunchPage,
  BMainNavigator,
  CMainNavigator
}
const SwitchStackNavigatorConfig = {
  initialRouteName: 'LaunchPage',
  headerMode: 'none',
  transition: (
    <Transition.Together>
      <Transition.Out type="fade" durationMs={300} interpolation="easeOut" />
      <Transition.In type="fade" durationMs={300} />
    </Transition.Together>
  )
}
const RootNavigator = createAnimatedSwitchNavigator(
  SwitchRouteConfigs,
  SwitchStackNavigatorConfig
)
const AppContainer = createAppContainer(RootNavigator)

export default AppContainer
